/*
 * Copyright 2019-2025 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * https://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.iiifi.kite.launcher.service;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;

import com.iiifi.kite.launcher.enums.KiteEnv;

/**
 * launcher 扩展 用于一些组件发现
 *
 * @author kite@iiifi.com 花朝
 */
public interface LauncherService extends Ordered, Comparable<LauncherService> {

    /**
     * 启动时 处理 SpringApplicationBuilder
     *
     * @param builder SpringApplicationBuilder
     * @param env 系统变量 Environment
     * @param appName 服务名
     * @param kiteEnv kiteEnv
     * @param isLocalDev 是否本地开发
     */
    void launcher(SpringApplicationBuilder builder, Environment env, String appName, KiteEnv kiteEnv,
            boolean isLocalDev);

    /**
     * 顺序
     *
     * @return int
     */
    @Override
    default int getOrder() {
        return Ordered.LOWEST_PRECEDENCE;
    }

    /**
     * 比较
     *
     * @param o o
     * @return int
     */
    @Override
    default int compareTo(LauncherService o) {
        return Integer.compare(this.getOrder(), o.getOrder());
    }

}
